package org.chengyi.model_shop.controller;

import org.chengyi.model_shop.entity.User;
import org.chengyi.model_shop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/userList")
    public List<User> getUserList() {
        return userService.getUserList();
    }

    @GetMapping("/userListByUsername")
    public List<User> getUserListByUsername(String username) {
        return userService.getUserListByUsername(username);
    }
    @DeleteMapping("/deleteUser")
    public String deleteUser(Integer id) {
        return userService.deleteUser(id);
    }
    @PutMapping("/updateUser")
    public int updateUser(@RequestBody User user) {
        return userService.updateUser(user);
    }
}
